<!-- 学年管理 -->
<div class="wrapper">
	<!-- second-nav -->
	<!-- <div ng-include="'main/manage/nav.html'"></div> -->
	<!-- wrapper-content -->
	<section class="wrapper-content">
		<div class="container-fluid">
			<h2 class="content-title"><span class="margin-right-10">学年管理</span><small>学年列表</small></h2>
		</div>
		<!-- btn-row -->
		<div class="btn-row clearfix">
			<div class="col-md-6">
				<button class="btn btn-primary" ng-click="openAdd()">添加</button>
			</div>
		</div>
		<!-- table-row -->
		<div class="row">
			<div class="container-fluid">
				<div class="col-md-12">
					<table class="table table-bordered" ng-table="yearList">
						<tr ng-repeat="item in $data">
							<td title="'名称'" sortable="'name'">{{item.name}}</td>
							<td title="'学年起止日期'" sortable="'date'">{{item.date}}</td>
							<td title="'上学期起止日期'" sortable="'firstDate'">{{item.firstDate}}</td>
							<td title="'下学期起止日期'" sortable="'secondDate'">{{item.secondDate}}</td>
							<td title="'是否当前学年'">
								<div ng-if="item.status == 2">
									<span class="margin-right-10">是</span>
								</div>
								<div ng-if="item.status == 1">
									<span class="margin-right-10">否</span>
									<button href="javascript:void(0);" ng-click="openCurYear(item);" class="btn btn-sm btn-danger" title="设置为当前学年"><i class="fa fa-cog"></i></button>
								</div>
							</td>
							<td title="'操作'">
								<div class="btn-group">
	                                <button href="javascript:void(0);" ng-click="openEdit(item);" class="btn btn-sm btn-success" title="编辑"><i class="fa fa-pencil"></i></button>
	                                <button href="javascript:void(0);" ng-if="item.status == 1" ng-click="openDel(item);" class="btn btn-sm btn-warning" title="删除"><i class="fa fa-times"></i></button>
	                            </div>
							</td>
						</tr>
					</table>
					<div class="row">
						<div class="col-md-6">
							<div class="pull-left btn btn-default">总数：<span class="badge">{{ totalRow }}</span></div>	
						</div>
						<div class="col-md-6">
							<!-- 分页 -->
							<nav>
								<ul class="pagination ng-table-pagination fr">
									<li>
										<a ng-click="previous()"><span>上一页</span></a>
									</li>
									<li ng-repeat="page in pageList" ng-class="{active: isActivePage(page)}" >
										<a ng-click="getYearList(page)">{{ page }}</a>
									</li>
									<li>
										<a ng-click="next()"><span>下一页</span></a>
									</li>
								</ul>
							</nav>
						</div>
					</div>
				</div>
			</div>
		</div>
		
		<!-- 新增 addYearModel -->
		<div class="modal" id="addYearModel" tabindex="-1" role="dialog">
			<div class="modal-dialog modal-lg" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        				<h3 class="modal-title">新增学年</h3>
					</div>
					<div class="modal-body">
						<div class="form-horizontal">
							<!-- 用户名 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="true" class="text-danger">*</span>
								    <label for="inputName">请选择需要新建的学年</label>
								</div>
								<div class="col-md-6">
									<select class="form-control" ng-model="newYearItem.selectYear" ng-options="item.label for item in years" ng-change="selectYear()"></select>
									<p>学年名称：{{newYearItem.name}}</p>
								</div>
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-primary" ng-click="addYear()">确认</button>
						<button type="button" class="btn btn-warning" data-dismiss="modal">取消</button>
					</div>
				</div>
			</div>
		</div>

		<!-- 修改 editYearModel -->
		<div class="modal" id="editYearModel" tabindex="-1" role="dialog">
			<div class="modal-dialog modal-lg" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        				<h3 class="modal-title">编辑学年</h3>
					</div>
					<div class="modal-body">
						<div class="form-horizontal">
							<!-- 名称 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="true" class="text-danger">*</span>
								    <label for="inputName">名称</label>
								</div>
								<div class="col-md-7">
									<input id="inputName" name="inputName" class="form-control" placeholder="名称" type="text" ng-model="modYearItem.name" ng-change="watchName()">
								</div>
								<div class="col-md-2 text-danger" ng-bind="modYearItem.warn.name"></div>
							</div>
							<!-- 学年起止日期 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="true" class="text-danger">*</span>
								    <label>学年起止日期</label>
								</div>
								<div class="col-md-7">
									<div class="row">
										<div class="col-sm-6">
											<div class="input-group">
												<input type="text" class="form-control myDatePicker" data-format="yyyy-mm-dd" id="startDate" ng-model="modYearItem.firstStartDate" ng-change="watchDate()" ng-disabled="'true'">
												<span class="input-group-btn">
													<button class="btn default" type="button" ng-click="openDate($event.target)"><i class="fa fa-calendar" ng-disabled="'true'"></i></button>
												</span>
											</div>
										</div>
										<div class="col-sm-6">
											<div class="input-group">
												<input type="text" class="form-control myDatePicker" id="endDate" ng-model="modYearItem.secondEndDate" ng-change="watchDate()" ng-disabled="'true'">
												<span class="input-group-btn">
													<button class="btn default" type="button" ng-click="openDate($event.target)"><i class="fa fa-calendar" ng-disabled="'true'"></i></button>
												</span>
											</div>
										</div>
									</div>
								</div>
							</div>
							<!-- 上学期起止日期 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="true" class="text-danger">*</span>
								    <label>上学期起止日期</label>
								</div>
								<div class="col-md-7">
									<div class="row">
										<div class="col-sm-6">
											<div class="input-group">
												<input type="text" class="form-control myDatePicker" id="firstStartDate" ng-model="modYearItem.firstStartDate" ng-change="watchDate()">
												<span class="input-group-btn">
													<button class="btn default" type="button" ng-click="cleanDate($event.target)"><i class="fa fa-times"></i></button>
													<button class="btn default" type="button" ng-click="openDate($event.target)"><i class="fa fa-calendar"></i></button>
												</span>
											</div>
											<div class="text-danger" ng-bind="modYearItem.warn.firstStartDate"></div>
										</div>
										<div class="col-sm-6">
											<div class="input-group">
												<input type="text" class="form-control myDatePicker" id="firstEndDate" ng-model="modYearItem.firstEndDate"  ng-change="watchDate()">
												<span class="input-group-btn">
													<button class="btn default" type="button" ng-click="cleanDate($event.target)"><i class="fa fa-times"></i></button>
													<button class="btn default" type="button" ng-click="openDate($event.target)"><i class="fa fa-calendar"></i></button>
												</span>
											</div>
											<div class="text-danger" ng-bind="modYearItem.warn.firstEndDate"></div>
										</div>
									</div>
								</div>
							</div>
							<!-- 下学期起止日期 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="true" class="text-danger">*</span>
								    <label>下学期起止日期</label>
								</div>
								<div class="col-md-7">
									<div class="row">
										<div class="col-sm-6">
											<div class="input-group">
												<input type="text" class="form-control myDatePicker" id="secondStartDate" ng-model="modYearItem.secondStartDate" ng-change="watchDate()">
												<span class="input-group-btn">
													<button class="btn default" type="button" ng-click="cleanDate($event.target)"><i class="fa fa-times"></i></button>
													<button class="btn default" type="button" ng-click="openDate($event.target)"><i class="fa fa-calendar"></i></button>
												</span>
											</div>
											<div class="text-danger" ng-bind="modYearItem.warn.secondStartDate"></div>
										</div>
										<div class="col-sm-6">
											<div class="input-group">
												<input type="text" class="form-control myDatePicker" id="secondEndDate" ng-model="modYearItem.secondEndDate" ng-change="watchDate()">
												<span class="input-group-btn">
													<button class="btn default" type="button" ng-click="cleanDate($event.target)"><i class="fa fa-times"></i></button>
													<button class="btn default" type="button" ng-click="openDate($event.target)"><i class="fa fa-calendar"></i></button>
												</span>
											</div>
											<div class="text-danger" ng-bind="modYearItem.warn.secondEndDate"></div>
										</div>
									</div>
								</div>
							</div>
							<!-- 错误提示 -->
							<div class="row text-danger">
								<div class="col-md-3"></div>
								<div class="col-md-7" ng-bind-html="modYearItem.warn.dateTips | toHtml"></div>
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-primary" ng-click="editYear()">确认</button>
						<button type="button" class="btn btn-warning" data-dismiss="modal">取消</button>
					</div>
				</div>
			</div>
		</div>

		<!-- 删除 delYearModel -->
		<div class="modal" id="delYearModel" tabindex="-1" role="dialog">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        				<h3 class="modal-title">删除学年</h3>
					</div>
					<div class="modal-body">
						<p class="text-danger text-center">删除学年将造成相关数据丢失，请确认是否继续删除。</p>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-primary" ng-click="delYear()">确认</button>
						<button type="button" class="btn btn-warning" data-dismiss="modal">取消</button>
					</div>
				</div>
			</div>
		</div>
		<!-- 设置当前学年 setCurYearModal -->
		<div class="modal" id="setCurYearModal" tabindex="-1" role="dialog">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        				<h3 class="modal-title">编辑学年</h3>
					</div>
					<div class="modal-body">
						<p class="text-danger text-center">当前学年只能存在一个，设置该学年将移除其他学年的当前状态，请确定是否继续。</p>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-primary" ng-click="setCurYear()">确认</button>
						<button type="button" class="btn btn-warning" data-dismiss="modal">取消</button>
					</div>
				</div>
			</div>
		</div>

		<!-- 提示 infoModel -->
		<info-modal msg="msg" visible="visible"></info-modal>
	</section>
</div>